﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApTcNewObject
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections;
using System.Drawing;
using System.Linq;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands;

public class CApTcNewObject
{
  private ITxObject m_parentObj;

  public CApTcNewObject(ITxObject parent) => this.m_parentObj = parent;

  internal bool CanHaveDescription(TxPlanningTypeMetaData metaData)
  {
    bool flag = false;
    if (metaData != null && !metaData.IsDerivedFromPlanningType("MEWorkareaRevision") && !metaData.IsDerivedFromPlanningType("AppearanceGroup"))
      flag = true;
    return flag;
  }

  internal ArrayList GetTypesToDisplay()
  {
    ArrayList typesToDisplay = new ArrayList();
    if (this.m_parentObj is ITxProcessModelObject parentObj && parentObj.PlanningRepresentation != null && parentObj.PlanningRepresentation.PlatformServicesProvider is ITxTcAnyServicesProvider servicesProvider)
      typesToDisplay.AddRange((ICollection) servicesProvider.AllowedChildrenTypes.ToArray<TxPlanningTypeMetaData>());
    return typesToDisplay;
  }

  internal static TxPlanningTypeMetaData GetTypeMetaData(string type)
  {
    TxPlanningTypeMetaData typeMetaData = (TxPlanningTypeMetaData) null;
    if (TxApplication.ActiveDocument.PlatformGlobalServicesProvider is ITxTcAnyGlobalServicesProvider servicesProvider)
      typeMetaData = ((ITxPlatformGlobalServicesProvider) servicesProvider).GetTypeMetaData(type);
    return typeMetaData;
  }

  internal Image GetIconFromType(string planningType)
  {
    return TxImageProvider.GetImageByPlanningType(planningType);
  }

  internal bool Create(string objName, string objDescription, string objType)
  {
    TxPlanningTypeMetaData typeMetaData = CApTcNewObject.GetTypeMetaData(objType);
    return typeMetaData != null && new CApTcNewObjectCreationFactory().CreateChildByType(this.m_parentObj, objName, objDescription, typeMetaData);
  }
}
